/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG                        *
*Copyright (C) 2006, Tony Sparks                                                     *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

#include "mmanager.h"
#include "./render/image.h"
#include "./render/textureloader.h"
#include "./sound/soundsource.h"
#include "./sound/soundloader.h"
#include "Console.h"

/**
====================================
Resource Cache- is an easy to access
resource loader, does not contain any
references to actual resources, each
subsystem has its own resource management
====================================
*/
class Resource : public IMMObject
{
public:
    Resource(void);

    /** Load Images */
    Image LoadSingleImage(const std::string &s);
    Image LoadImages(const std::string &s, int r, int c);

	/** Load a sound file */
	SoundSource* LoadSound( const std::string &s );


    /** Load a zip archive into memory */
    void LoadArchive( const std::string &zip );

    /** Number of sounds in cache */
    int Sounds();
    /** Number of textures in cache */
    int Textures();

    AUTO_SIZE;
    

private:
     // Manage textures
    TextureLoader   m_textureLoader;

    // For loading archives through the console
    class LoadArchive_f : public ICommand
    {   
    public:
        LoadArchive_f() {};
        ~LoadArchive_f() {};
        void Set(Resource* r) { m_res = r; };
        // load an archive into memory
        void Exec(std::string &s) {
            m_res->LoadArchive( s );
        };
    private:
        Resource* m_res;
    };
    Resource::LoadArchive_f   loadArc_f;
public:
    virtual ~Resource(void);
};
